home *** CD-ROM | disk | FTP | other *** search
- Path: cscsun3.larc.nasa.gov!hook
- From: hook@cscsun3.larc.nasa.gov (Ed Hook)
- Newsgroups: comp.lang.c
- Subject: Re: HELP: Illegal Pointer Arithmetic
- Date: 25 Feb 1996 17:45:15 GMT
- Organization: CSC/NASA Langley Research Center
- Distribution: world
- Message-ID: <4gq77b$bmo@reznor.larc.nasa.gov>
- References: <4gj0ug$730@news.one.net> <danpop.825121139@rscernix> <31306a18.309961701@nntp.ix.netcom.com>
- Reply-To: hook@cscsun3.larc.nasa.gov
- NNTP-Posting-Host: cscsun3.larc.nasa.gov
-
- In article <31306a18.309961701@nntp.ix.netcom.com>, miker3@ix.netcom.com (Mike Rubenstein) writes:
- |> danpop@mail.cern.ch (Dan Pop) wrote:
- |>
- |> > In <4gj0ug$730@news.one.net> Oren Levin <oren@one.net> writes:
- |> >
- |> > > while (! feof (fin))
- |> > ^^^^^^^^^^^^^^^^^^^^
- |> > Are there any books teaching this idiocy or is it only Pascal-induced
- |> > brain damage? (See the FAQ.)
- |>
- |> Not quite that, but Shildt's Annotated ANSI C Standard says
- |>
- |> The following fragment illustrates how files are commonly
- |> read:
- |>
- |> do {
- |> ch = fgetc(fp);
- |> /* ... */
- |> } while (!feof(fp));
- |>
- |> Come on Dan. You're slipping. Surely you could have guessed who
- |> teaches this idiocy.
- |>
- It depresses me to have to defend Schildt, but that loop actually
- works as advertised. (I *do* question his use of "commonly", since
- I have encountered _any_ code that does it that way ... .) Anyhow,
- since 'feof()' is called *after* each iteration of the loopbody,
- the loop terminates precisely after the last character is fetched
- from the file.
-
- |>
- |> Michael M Rubenstein
-
- --
- Ed Hook | Coppula eam, se non posit
- Computer Sciences Corporation | acceptera jocularum.
- NASA Langley Research Center | Me? Speak for my employer?...<*snort*>
- Internet: hook@cscsun3.larc.nasa.gov | ... Get a _clue_ !!! ...
-